package homework.student;

import java.util.ArrayList;
import java.util.Scanner;

public class Stuway {
    Scanner sc = new Scanner(System.in);
    ArrayList<Student> students = new ArrayList<Student>();
    public void mainMenu(){
        System.out.println("============学员信息管理系统============");
        System.out.println("|         1.显示学员信息            |");
        System.out.println("|         2.新增学员信息            |");
        System.out.println("|         3.修改学员信息            |");
        System.out.println("|         4.删除学员信息            |");
        System.out.println("|         5.安全退出系统            |");
        System.out.print("请您输入要操作的功能序号:");

    }
    public int choose(){
        return sc.nextInt();
    }
    public void init (ArrayList<Student> students){
        students.add(new Student("郭豪","1001","3232562000",19));
        students.add(new Student("乔加军","1002","3232562001",18));
        students.add(new Student("李刚洋","1003","3232562002",17));
    }
    public void showAllStudents(ArrayList<Student> students){
        for (int i = 0,size = students.size(); i < size; i++) {
            Student s = students.get(i);
            System.out.println(s);
        }
    }
    public void addStudents(ArrayList<Student> students){
        System.out.println("请输入你要添加的信息：");
        Student s  = new Student();
        System.out.print("请输入学生姓名：");
        s.setName(sc.nextLine());
        System.out.print("请输入学号：");
        s.setNumber(sc.nextLine());
        System.out.print("请输入身份证号：");
        s.setID(sc.nextLine());
        System.out.print("请输入学生的年龄：");
        s.setAge(sc.nextInt());
        System.out.println("添加成功！");
    }
    public void deleteStudents(ArrayList<Student> students){
        System.out.println("选择的是删除功能");
        System.out.print("请输入学生学号：");
        String num = sc.nextLine();
        for (int i = 0,size = students.size(); i < size; i++) {
            Student s = students.get(i);
            if (s.getNumber().equals(num)){
                students.remove(i);
                System.out.println("删除成功！");

                return;
            }
        }
        System.out.println("你输入的学号不存在！");

    }

    public void updataStudents(ArrayList<Student> students){
        System.out.println("选择的是修改功能");
        System.out.print("请输入学生学号：");
        String num = sc.nextLine();
        for (int i = 0,size = students.size(); i < size; i++) {
            Student s = students.get(i);
            if (s.getNumber().equals(num)){
                System.out.print("请输入学生的新姓名：");
                s.setName(sc.nextLine());
                System.out.print("请输入学生的新学号：");
                s.setNumber(sc.nextLine());
                System.out.print("请输入学生的新身份证号：");
                s.setID(sc.nextLine());
                System.out.print("请输入学生的新年龄：");
                s.setAge(sc.nextInt());
                System.out.println("修改成功！");
                return;
            }
        }
    }

    public boolean Log() {
        while (true) {
            Manger Man = new Manger("admin", "123");
            System.out.println("***********欢迎进入学生管理系统**********");
            System.out.print("请输入用户名:");// manger
            Scanner sc = new Scanner(System.in);
            String manger = sc.nextLine();
            System.out.print("请输入密码:");
            String password = sc.next();

            if ((Man.getManname().equals(manger))
                    && (Man.getManpassword().equals(password))) {
                System.out.println("登陆成功");
                return true;
            } else {
                System.out.println("登陆失败");
                return false;
            }
        }

    }

}
